package com.example.uitest;

import android.app.Activity;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

public class BaseActivty extends Activity {
	
	public static Typeface mTypeface;
	
	@Override
	public void setContentView(int layoutResID){
		super.setContentView(layoutResID);
		
		if(BaseActivty.mTypeface == null){
			BaseActivty.mTypeface = Typeface.createFromAsset(getAssets(), "ababoo.otf");
		}
		
		ViewGroup root = (ViewGroup)findViewById(android.R.id.content);
		setGlobalFont(root);
	}
	
	void setGlobalFont(ViewGroup root){		
		for(int i = 0; i<root.getChildCount(); i++){
			View child = root.getChildAt(i);
			if(child instanceof TextView){
				((TextView)child).setTypeface(mTypeface);
			}
			else if(child instanceof ViewGroup){
				setGlobalFont((ViewGroup)child);
			}
		}
	}

}
